﻿using AutoMapper;
using MediatR;
using PersonnelManagement.Application.Command.ManpowerCommand;
using PersonnelManagement.Domain.PersonnelDomain;
using PersonnelManagement.Infrstructre.Interface;

namespace PersonnelManagement.Application.CommandHandler.ManpowerCommandHandler
{
    public class UpdManpowerCommandHandler : IRequestHandler<UpdManpowerCommand, int>
    {
        IManpowerRepostiory mRep;
        IMapper mapper;

        public UpdManpowerCommandHandler(IManpowerRepostiory mRep, IMapper mapper)
        {
            this.mRep = mRep;
            this.mapper = mapper;
        }

        public async Task<int> Handle(UpdManpowerCommand request, CancellationToken cancellationToken)
        {
            return await mRep.UpdateAsymc(mapper.Map<Manpower>(request.UpdDtos));
        }
    }
}
